//
//  Detailed_SingerVC.m
//  K-Music
//
//  Created by CHUN on 16/2/19.
//  Copyright © 2016年 CHUN. All rights reserved.
//

#import "Detailed_SingerVC.h"

@interface Detailed_SingerVC ()

@end

@implementation Detailed_SingerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self get_singer];
    // Do any additional setup after loading the view.
}

- (void)get_singer
{
    [MBProgressHUD showWithStatus:@"加载中..." toView:self.view];
    
    AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager];
    
    NSString * Id = [NSString stringWithFormat:@"%@",self.Sing_ID];
    
    NSString*infoStr11=[NSString stringWithFormat:@"/api/singer_category/category_id/%@/singers",Id];
    
    NSString *intactURL = [MyBaseUrl stringByAppendingString:infoStr11];
    
    NSString * token = [FileStorage NSUserDefault_getObjectForKey:access_token];
    
    //    创建请求
    manager.requestSerializer =[AFHTTPRequestSerializer serializer];
    
    [manager.requestSerializer setValue:@"application/json"
                     forHTTPHeaderField:@"Accept"];
    [manager.requestSerializer setValue:[NSString stringWithFormat: @"Bearer %@",token]
                     forHTTPHeaderField:@"Authorization"];
    
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager GET:intactURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil];
        
        NSLog(@"成功GET --> fans%@", dic);
        _Singer_Datas = [NSMutableArray array];
        NSArray * arr = dic[@"body"];
        NSArray * Datas = [Detailed_Singer_mode objectArrayWithKeyValuesArray:arr];
        _Singer_Datas = [NSMutableArray arrayWithArray:Datas];
        
        [User_information conversion].fans_Data = [ _Singer_Datas copy];
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"%@",error);
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [MBProgressHUD showErrorWithStatus:@"数据获取失败" toView:self.view];
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
